package com.honey.mybatis.generator.dao;

import com.honey.compilation.java.AbstractJavaCompilation;
import com.honey.compilation.java.Interface;
import com.honey.core.compiler.CompilationException;
import com.honey.core.dbmapping.introspect.IntrospectSchema;
import com.honey.core.dbmapping.introspect.IntrospectSchemaColumn;
import com.honey.core.dbmapping.structure.Schema;
import com.honey.core.types.FullyQualifiedJavaType;
import com.honey.mybatis.generator.AbstractClass;
import com.honey.mybatis.generator.MybatisPlugin;

public class DaoInterface extends AbstractClass {
	
	public DaoInterface(MybatisPlugin belongPlugin,
			IntrospectSchema introspectSchema,
			IntrospectSchemaColumn introspectSchemaColumn) {
		super(belongPlugin, introspectSchema, introspectSchemaColumn);
	}

	/* (non-Javadoc)
	 * @see com.honey.mybatis.generator.AbstractClass#getAbstractJavaCompilation()
	 */
	@Override
	protected AbstractJavaCompilation getAbstractJavaCompilation()
			throws CompilationException {
		Schema schema = introspectSchema.getSchema();
		Interface answer = null;
		try {
			String entity = super.getClassName( schema, mybatisPlugin.getEntityClassSuffix());
			answer =new Interface(super.getInterfaceClassType(schema,"<E extends " + entity + ">"));
			answer.addImportedType(super.getModelPrimitiveClassType(introspectSchema.getSchema()));
			answer.addImportedType(super.getEntityPrimitiveClassType(schema));
			
		} catch (CompilationException e) {
			e.printStackTrace();
		}
		return answer;
	}
	
	@Override
	protected FullyQualifiedJavaType getType() {
		
		return null;
	}

}
